import { reactive } from "vue";
import { DataStorageExtension } from "./useListCore";
import { cacheModel } from "./useListCore.type";
function getRandomIntInclusive(min: number, max: number) {
    return Math.floor(Math.random() * (max - min + 1)) + min; // 含最大值，含最小值
}
const randomCreateData = (func: (item: cacheModel) => void) => {
    const randomNum = getRandomIntInclusive(1, 20);
    const randomTime = getRandomIntInclusive(20, 100);
    setTimeout(() => {
        for (let i = 0; i < randomNum; i++) {
            const item: cacheModel = {
                title: +new Date() + "-假数据" + i
            };
            func(item);
        }
        randomCreateData(func);
    }, randomTime);
};
export default () => {
    const dataStorageExtension = new DataStorageExtension();
    // randomCreateData((item: cacheModel) => {
    //     dataStorageExtension.add(item);
    // });
    const getData = () => {
        setTimeout(() => {
            getData();
            console.log("dataStorageExtension", dataStorageExtension.cacheLength);
            console.log("dataStorageExtension", dataStorageExtension.currentKey);
        }, 1000);
    };
    getData();
    const list = reactive([]);
    return {
        list
    };
};
